package com.accenture.adf.newcodington.module13.sample;

/**
 * 
 * Topic: Error Handling using Try-Catch clause
 * 
 * Instructions:
 * 1. Implement error handling using try-catch in the display() method
 * 2. Create a TryCatchDemo object in the main() method
 * 3. Invoke the display() method
 *
 */

public class TryCatchDemo {

	public static void main(String[] args) {
		
		//Create an object of TryCatchDemo class
		TryCatchDemo obj = new TryCatchDemo();

		//call display method
		obj.display();
	}

	public void display()
	{
		
		try
		{
		//Create a String variable and initialize it with a name 
		String name = "Accenture";
		
		//Use Integer.parseInt to convert this to a number
		int value = Integer.parseInt(name);
		
		//Print this integer 
		System.out.println(value);
		}
		
		//Handle appropriate Exception
		catch(NumberFormatException e)
		{
			System.out.print("There is a problem with the number entered - ");
			System.out.println(e.getMessage());
		}
		
		
	}
}
